package mathwork;

public abstract class Integral {
	abstract protected Double f(Double x);
	public Double trapz(Double a,Double b){
		Double result=0.0;
		Double step=(Math.abs(a-b))/1000.0;
		Double start;
		Double end;
		if(a.compareTo(b)<0){
			start=a;
			end=b;
		}else{
			start=b;
			end=a;
		}
		
		Double loop;
		for(loop=start;loop.compareTo(end)<0;loop+=step){
			result+=this.f(loop)*step;
		}
		return result;
	}
}
